package com.sl.au.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.sl.au.entity.AfterSaleComplain;


@Transactional(readOnly = true)
public interface AfterSaleComplainRepository extends JpaRepository<AfterSaleComplain, String > {

    @Query(" select a from AfterSaleComplain a where a.customerName like '%'+?1+'%' or a.contractID like '%'+?1+'%' or a.contact like '%'+?1+'%' ")
    Page<AfterSaleComplain> findComplain(String key, Pageable pageable);

    AfterSaleComplain findById(String id);

    /**
     * 得到数据条数
     */
    @Query(" select count(a) from AfterSaleComplain a where a.customerName like '%'+?1+'%' or a.contractID like '%'+?1+'%' or a.contact like '%'+?1+'%' ")
    long getCount(String key);

}

